﻿using System;
using OneMG.Phoenix.Entity;
using OneMG.Phoenix.Respository;
using IBatisNet.DataMapper;
using OneMG.Phoenix.Kernel.IBatisUtil;
using System.Collections.Generic;

namespace OneMG.Phoenix.IBatisRepository
{
    public class CategoryRepository : BaseIBatisDao,ICategory
    {
        public CategoryRepository()
            : base("yihaoke_newMap.Config")
        {

        }
		public  ECategory GetByCategoryID (System.Int32 categoryID)
        {
			string stmtId = "CategoryMap.SelectByCategoryID";
			return base.SqlMapper.QueryForObject<ECategory>(stmtId, categoryID);
        }
        
        public  void DeleteByCategoryID (System.Int32 categoryID)
        {
			string stmtId = "CategoryMap.DeleteByCategoryID";
			base.SqlMapper.Update(stmtId, categoryID);
        }
        
        public  void UpdateByCategoryID (ECategory entity)
        {
			string stmtId = "CategoryMap.UpdateByCategoryID";
			base.SqlMapper.Update(stmtId, entity);
        }

        public System.Int32 AddCategory(ECategory entity)
        {
			string stmtId = "CategoryMap.InsertCategory";
			 Object obj = base.SqlMapper.Insert(stmtId, entity);
             return (int)obj;
        }

        public IList<ECategory> GetByParentID(System.Int32 parentID)
        {
            string stmtId = "CategoryMap.SelectByParentID";
            return SqlMapper.QueryForList <ECategory>(stmtId, parentID);

        }



    }
}

